package tools;

import org.resotc.model.IndividualType;



public class IDManager {

	private static IDManager instance = null;
	
	// Managed IDs
	private int highestCarID;
	private int highestLorryID;
	
	private IDManager(){
		highestCarID = 0;
		highestLorryID = 0;
	}
	
	public static IDManager getIDManager(){
		if(instance == null){
			instance = new IDManager();
		}
		return instance;
	}
	
	public int receiveNewID(IndividualType iType){
		if(iType == IndividualType.CAR){
			highestCarID++;
			return highestCarID;
		} else if (iType == IndividualType.LORRY){
			highestLorryID++;
			return highestLorryID;
		} else {
			System.err.println("[IDManager] ERROR: Cannot determine new ID, unknown type!");
			return -1;
		}
	}
}
